home *** CD-ROM | disk | FTP | other *** search
/ Delphi Informant Complete 1995 - 2000 / Delphi Informant Complete 1995 to 2000.iso / Delphi Informant Magazine Complete Works SOURCE CODE 1995.rar / 1995 / NOV / CJ9511 / unit1.pas < prev    next >
Pascal/Delphi Source File  |  1995-09-26  |  2KB  |  95 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, DB, Grids, DBGrids, DBTables, Unit2;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     SaveDialog1: TSaveDialog;
  12.     Memo1: TMemo;
  13.     BatchMove1: TBatchMove;
  14.     Query1: TQuery;
  15.     Button1: TButton;
  16.     DBGrid1: TDBGrid;
  17.     Button2: TButton;
  18.     DataSource1: TDataSource;
  19.     Label1: TLabel;
  20.     Label2: TLabel;
  21.     ComboBox1: TComboBox;
  22.     Label3: TLabel;
  23.     ComboBox2: TComboBox;
  24.     Label4: TLabel;
  25.     Button3: TButton;
  26.     Table1: TTable;
  27.     procedure Button3Click(Sender: TObject);
  28.     procedure FormCreate(Sender: TObject);
  29.     procedure ComboBox1Change(Sender: TObject);
  30.     procedure Button1Click(Sender: TObject);
  31.     procedure Button2Click(Sender: TObject);
  32.   private
  33.     { Private declarations }
  34.   public
  35.     { Public declarations }
  36.   end;
  37.  
  38. var
  39.   Form1: TForm1;
  40.  
  41. implementation
  42.  
  43. {$R *.DFM}
  44.  
  45. procedure TForm1.Button3Click(Sender: TObject);
  46. begin
  47. Query1.Close;
  48. Query1.DatabaseName := ComboBox1.Text;
  49. Query1.SQL := Memo1.Lines;
  50. Query1.Open;
  51. end;
  52.  
  53. procedure TForm1.FormCreate(Sender: TObject);
  54. begin
  55. Session.GetAliasNames(ComboBox1.Items);
  56. Application.ProcessMessages;
  57. ComboBox1.ItemIndex := 0;
  58. ComboBox1Change(Sender);
  59. end;
  60.  
  61. procedure TForm1.ComboBox1Change(Sender: TObject);
  62. begin
  63. ComboBox2.Items.Clear;
  64. Session.GetTableNames(ComboBox1.Text,'*.*',False,False,ComboBox2.Items);
  65. end;
  66.  
  67. procedure TForm1.Button1Click(Sender: TObject);
  68. begin
  69. if Query1.Active = False then
  70.   Exit;
  71. if SaveDialog1.Execute then begin
  72.   Table1.TableName := SaveDialog1.Filename;
  73.   with BatchMove1 do begin
  74.     Source := Query1;
  75.     Destination := Table1;
  76.     Mode := batCopy;
  77.     Execute;
  78.     ShowMessage(IntToStr(MovedCount)+' records copied');
  79.   end;
  80. end;
  81. end;
  82.  
  83. procedure TForm1.Button2Click(Sender: TObject);
  84. begin
  85. if Table1.TableName <> '' then begin
  86.   Form2.Caption := Table1.TableName;
  87.   Form2.Table1.TableName := SaveDialog1.Filename;
  88.   Form2.Table1.Open;
  89.   Form2.ShowModal;
  90.   Form2.Table1.Close;
  91. end;
  92. end;
  93.  
  94. end.
  95.